package com.yunmang.adapter;

import android.annotation.SuppressLint;
import android.content.Context;
import android.graphics.Color;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.ImageView;
import android.widget.TextView;

import com.yunmang.R;
import com.yunmang.entity.NodeBean;

import java.util.List;

@SuppressLint("ResourceAsColor")
public class TimeAdapter extends BaseAdapter {
    private Context context;  
    private List<NodeBean> list;
     private LayoutInflater inflater;    
       
     public TimeAdapter(Context context, List<NodeBean> list) {
            super();    
            this.context = context;    
            this.list = list;    
        }    
  
    public TimeAdapter() {
	}

	@Override  
    public int getCount() {  
        return list.size();
    }  
  
    @Override  
    public Object getItem(int position) {  
        return position;  
    }  
  
    @Override  
    public long getItemId(int position) {  
        return position;  
    }  
  
    @SuppressLint("ResourceAsColor") @Override  
    public View getView(int position, View convertView, ViewGroup parent) {
        NodeBean bb= list.get(position);
        TimeLineHolder viewHolder = null;    
        if (convertView == null) {    
            inflater = LayoutInflater.from(parent.getContext());    
            convertView = inflater.inflate(R.layout.item_lv_trace, null);
            viewHolder = new TimeLineHolder();    
            viewHolder.title = (TextView) convertView.findViewById(R.id.title);    
            viewHolder.time = (TextView) convertView.findViewById(R.id.time);    
            viewHolder.iv_image=(ImageView) convertView.findViewById(R.id.image);
            convertView.setTag(viewHolder);    
        } else {    
            viewHolder = (TimeLineHolder) convertView.getTag();    
        }    
        String titleStr =bb.notes;
        viewHolder.title.setText(titleStr);    
        viewHolder.time.setText(bb.actionTime);
        if(position==0){
        	viewHolder.iv_image.setImageResource(R.mipmap.trace_ok);
        	viewHolder.title.setTextColor(Color.BLUE);
        	viewHolder.time.setTextColor(Color.BLUE);
        }else{
        	viewHolder.iv_image.setImageResource(R.mipmap.trace);
        	viewHolder.title.setTextColor(Color.BLACK);
        	viewHolder.time.setTextColor(Color.BLACK);
        }
        return convertView;    
    }  
    static class TimeLineHolder{  
        private TextView title,time;  
        private ImageView iv_image;
    }  
  
}  